package com.fc.entities;

import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.ManyToOne
import javax.persistence.Table
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Size


/**
 * 
 * @author Ács Ádám
 * 
 */
@Entity
@Table(name = "Food")
class Food extends BaseEntity {
	@Column(name = "name")
	@NotNull
	@Size(min=3, max=64)
	String name

	@Column(name = "calorie")
	@Max(99999L)
	@Min(0L)
	Integer calorie

	@Column(name = "protein")
	@Max(99999L)
	@Min(0L)
	BigDecimal protein

	@Column(name = "carbohydrate")
	@Max(99999L)
	@Min(0L)
	BigDecimal carbohydrate

	@Column(name = "fat")
	@Max(99999L)
	@Min(0L)
	BigDecimal fat

	@Column(name = "fiber")
	@Max(99999L)
	@Min(0L)
	BigDecimal fiber

	@Column(name = "quantity")
	@Min(0L)
	@NotNull
	BigDecimal quantity
	
	@ManyToOne
	@NotNull
	UnitOfMeasurement unitOfMeasurement

	@ManyToOne
	@NotNull
	FoodGroup foodGroup
	
	@ManyToOne
	@NotNull
	User user

	/**
	 * glikémiás index nem jelenik meg kaja felvételénél, de adatbázisba a rendszer felveheti	
	 */
	@Column(name="glicemicIndex")
	/* Nullable */ 
	@Max(200L)
	Integer glicemicIndex
	
	@Override
	String toString() {
		return name
	}
}
